#include "list.h"
class Pos {
public:
	Pos(int col = 0, int row = 0)
		:_col(col),
		_row(row)
	{
		//cout << "Pos(int col, int row)" << endl;
	}
	Pos(const Pos& p)
		:_col(p._col),
		_row(p._row)
	{
		//cout << "Pos(const Pos& p)" << endl;
	}
	int _col;
	int _row;
};
//int main()
//{
//	list<Pos> lt;
//	//构造+拷贝构造
//	Pos p1(1, 1);
//	lt.push_back(p1);
//	lt.push_back(Pos(2, 2));
//	lt.push_back({ 3,3 });
//
//	lt.emplace_back(p1);
//	lt.emplace_back(Pos(2, 2));
//	//直接构造
//	lt.emplace_back(3, 3);
//	return 0;
//}
void Test1()
{
	/*MyList::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	lt.push_back(5);
	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;*/

	MyList::list<Pos> lt;
	Pos p(1, 1);
	lt.push_back(p);
	lt.push_back(Pos(2, 2));
	auto it = lt.begin();
	while (it != lt.end())
	{
		cout << it->_row << " " << it->_col << endl;
		it++;
	}
}
void Test2()
{
	MyList::list<int> lt1;
	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);
	lt1.push_back(5);
	const MyList::list<int> lt(lt1);
	for (auto& e : lt)
	{
		cout << e << endl;
	}
}
void Test3()
{
	MyList::list<int> lt(10, 1);
	for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
	lt.push_back(2);
	lt.push_front(3);
	lt.pop_back();
	lt.pop_back();
	lt.pop_front();
	lt.pop_front();
	for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	lt.insert(lt.end(), 3, 3);
	for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	cout << lt.front() << " " << lt.back() << endl;
}
void Test4()
{
	MyList::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	MyList::list<int> lt1 = lt;
	lt1.insert(lt1.begin(), 3, 5);
	lt1.insert(lt1.end(), 3, 6);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	swap(lt, lt1);
}
void Test5()
{
	/*const MyList::list<int> lt = { 1,2,3,4,5,6 };
	MyList::list<int>::const_reverse_iterator rit = lt.rbegin();
	while (rit != lt.rend())
	{
		cout << *rit << " ";
		rit++;
	}
	cout << endl;*/

	const MyList::list<string> lt = { "hello world","hellow bit","hello C++" };
	MyList::list<string>::const_reverse_iterator rit = lt.rbegin();
	while (rit != lt.rend())
	{
		cout << *rit << " ";
		rit++;
	}
	cout << endl;
}
void Test6()
{
	MyList::list<int> lt = { 1,2,3,4,5,6 };
	for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
	auto it = lt.rbegin();
	while (it != lt.rend())
	{
		cout << *it << " ";
		it++;
	}
	cout << endl;
	MyList::list<int> lt1(lt);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}
void Test7()
{
	MyList::list<int> lt = { 1,2,3,4,5,6 };
	lt.insert(lt.begin(), 3, 7);
	lt.insert(lt.end(), 3, 8);
	for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
	MyList::list<int> lt1 = { 10,20,30 };
	lt1.insert(lt1.end(), lt.begin(), lt.end());
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}
void Test8()
{
	MyList::list<int> lt = { 1,2,3,4,5,6 };
	auto it = lt.begin();
	it++;
	it++;
	//lt.erase(it);
	lt.erase(it, lt.end());
	lt.push_back(3);
	lt.resize(6,6);
	//lt.clear();
	/*for (auto& e : lt)
	{
		cout << e << " ";
	}
	cout << endl;*/
	MyList::printContainer(lt);
	cout << lt.size() << endl;
}
void Test9()
{
	MyList::list<int> lt = { 1,2,3,4,5,6 };
	auto it = lt.rbegin();
	while (it != lt.rend())
	{
		cout << *it << " ";
		it++;
	}
}
int main()
{
	//Test1();
	//Test2();
	//Test3();
	//Test4();
	//Test5();
	//Test6();
	//Test7();
	//Test8();
	Test9();
	return 0;
}